package com.ruoyi.zhjd.laboratory.modules.laboratorymechanics.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.zhjd.laboratory.modules.laboratoryMechanicsWGroup.entity.MechanicsWFyDetailEntity;
import com.ruoyi.zhjd.laboratory.modules.laboratoryMechanicsWGroup.service.MechanicsWFyDetailService;
import com.ruoyi.zhjd.laboratory.modules.laboratoryMechanicsYGroup.entity.MechanicsYDetailEntity;
import com.ruoyi.zhjd.laboratory.modules.laboratoryMechanicsYGroup.entity.MechanicsYGroupEntity;
import com.ruoyi.zhjd.laboratory.modules.laboratoryMechanicsYGroup.service.MechanicsYDetailService;
import com.ruoyi.zhjd.laboratory.modules.laboratoryMechanicsYGroup.service.MechanicsYGroupService;
import com.ruoyi.zhjd.laboratory.modules.laboratorymechanics.entity.LaboratoryMechanicsAllPowerfulMachineDetailEntity;
import com.ruoyi.zhjd.laboratory.modules.laboratorymechanics.entity.LaboratoryMechanicsAllPowerfulMachineEntity;
import com.ruoyi.zhjd.laboratory.modules.laboratorymechanics.entity.LaboratoryMechanicsPressMachineDetailEntity;
import com.ruoyi.zhjd.laboratory.modules.laboratorymechanics.mapper.LaboratoryMechanicsPressMachineMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;




import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ruoyi.zhjd.laboratory.modules.laboratoryMechanicsWGroup.entity.MechanicsWDetailEntity;
import com.ruoyi.zhjd.laboratory.modules.laboratoryMechanicsWGroup.entity.MechanicsWGroupEntity;
import com.ruoyi.zhjd.laboratory.modules.laboratoryMechanicsWGroup.service.MechanicsWDetailService;
import com.ruoyi.zhjd.laboratory.modules.laboratoryMechanicsWGroup.service.MechanicsWGroupService;
import com.ruoyi.zhjd.laboratory.modules.laboratorymechanics.dto.LaboratoryMechanicsPressMachineDto;
import com.ruoyi.zhjd.laboratory.modules.laboratorymechanics.entity.LaboratoryMechanicsPressMachineEntity;
import com.ruoyi.zhjd.laboratory.modules.laboratorymechanics.service.LaboratoryMechanicsAllPowerfulMachineDetailService;
import com.ruoyi.zhjd.laboratory.modules.laboratorymechanics.service.LaboratoryMechanicsAllPowerfulMachineService;
import com.ruoyi.zhjd.laboratory.modules.laboratorymechanics.service.LaboratoryMechanicsPressMachineDetailService;
import com.ruoyi.zhjd.laboratory.modules.laboratorymechanics.service.LaboratoryMechanicsPressMachineService;

/**
 * @ClassName LaboratoryMechanicsPressMachineServiceImpl
 * @Description 压力机业务接口实现
 * @author cuiwenlong
 * @since
 */
@Service
public class LaboratoryMechanicsPressMachineServiceImpl extends ServiceImpl<LaboratoryMechanicsPressMachineMapper, LaboratoryMechanicsPressMachineEntity>
					implements LaboratoryMechanicsPressMachineService {
//	@Autowired
//    private BaseServiceComponent baseServiceComponent;
	/**
	 * 压力机详情
	 */
	@Autowired
	private LaboratoryMechanicsPressMachineDetailService detailService;
	/**
	 * mapper层
	 */
	@Autowired
	private LaboratoryMechanicsPressMachineMapper mapper;
	/**
	 * 万能机基础信息
	 */
	@Autowired
	private LaboratoryMechanicsAllPowerfulMachineService  powerfulMachineService;
	/**
	 * 万能机详情
	 */
	@Autowired
	private LaboratoryMechanicsAllPowerfulMachineDetailService powerfulMachineDetailService;
	@Override
	@Transactional
	public Map<String, Object> Upload(JSONObject json) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		if(json.get("Group")!=null&&json.getJSONObject("Group").get("_TestID_")!=null) {
			//获取上传信息
			JSONObject group= json.getJSONObject("Group");
			String testId=group.get("_TestID_").toString();
			try {
			//注：不同的软件的前缀是不一样的。
			//SuperTest的前缀是 ST_
			//TestMaster的前缀是 TM_
			String deviceType=testId.substring(0, 3);
			if ("ST_".equals(deviceType)) {
				//获取上传试样主表信息
				LaboratoryMechanicsPressMachineEntity pressEntity = new LaboratoryMechanicsPressMachineEntity();
				pressEntity.setSampleKey(group.get("_Key_").toString());
				pressEntity.setLingQi(group.get("_LingQi_").toString());
				pressEntity.setDeviceId(group.get("_DeviceID_").toString());
				pressEntity.setTestId(group.get("_TestID_").toString());
				pressEntity.setTester(group.get("_Tester_").toString());
				if(group.get("QDDJ")!=null) {
				pressEntity.setQddj(group.get("QDDJ").toString());
				}
				if(group.get("Size")!=null) {
				pressEntity.setSize(group.get("Size").toString());
				}
				if(group.get("XS")!=null) {
				pressEntity.setXs(group.get("XS").toString());
				}
				if(group.get("YXLZ")!=null) {
				pressEntity.setYxlz(group.get("YXLZ").toString());
				}
				if(group.get("YXQD")!=null) {
				pressEntity.setYxqd(group.get("YXQD").toString());
				}
				if(group.get("PDJG")!=null) {
				pressEntity.setPdjg(group.get("PDJG").toString());
				}
				//其他字段
				if(group.get("Shape")!=null) {
					pressEntity.setShape(group.get("Shape").toString());
				}
				if (group.get("Length")!=null) {
					pressEntity.setLength(group.get("Length").toString());
				}
				if (group.get("Width")!=null) {
					pressEntity.setWidth(group.get("Width").toString());
				}
				if (group.get("Height")!=null) {
					pressEntity.setHeight(group.get("Height").toString());
				}
				if (group.get("Diameter")!=null) {
					pressEntity.setDiameter(group.get("Diameter").toString());
				}
				if (group.get("Span")!=null) {
					pressEntity.setSpan(group.get("Span").toString());
				}
				if (group.get("Sample")!=null) {
					pressEntity.setSample(group.get("Sample").toString());
				}
				if (group.get("PingZhong")!=null) {
					pressEntity.setPinZhong(group.get("PingZhong").toString());
				}
				if (group.get("K")!=null) {
					pressEntity.setK(group.get("PingZhong").toString());
				}
				//存储试样主表信息
				this.save(pressEntity);
				//获取试样详细信息
				JSONArray detailArray= group.getJSONArray("Detail");
				List<LaboratoryMechanicsPressMachineDetailEntity> detailList = new ArrayList<LaboratoryMechanicsPressMachineDetailEntity>();
				for (Object object : detailArray) {
					JSONObject detailObj = (JSONObject) JSONUtil.parse(object);
					LaboratoryMechanicsPressMachineDetailEntity entity = new LaboratoryMechanicsPressMachineDetailEntity();
					entity.setSampleId(pressEntity.getId());
					entity.setSampleKey(group.get("_Key_").toString());
					entity.setDetailKey(detailObj.get("_Key_").toString());
					entity.setTime(detailObj.get("_Time_").toString());
					entity.setLoad(detailObj.get("Load").toString());
					entity.setStress(detailObj.get("Stress").toString());
					entity.setDatas(detailObj.get("_Datas_").toString());
					detailList.add(entity);
				}
				//试样详细信息批量插入数据库
				detailService.saveDetailData(detailList);
			}else if("TM_".equals(deviceType)) {
				//获取上传万能机试样主表信息
				LaboratoryMechanicsAllPowerfulMachineEntity powerfulEntity = new LaboratoryMechanicsAllPowerfulMachineEntity();
				powerfulEntity.setSampleKey(group.get("_Key_").toString());
				powerfulEntity.setDeviceId(group.get("_DeviceID_").toString());
				powerfulEntity.setTestId(group.get("_TestID_").toString());
				powerfulEntity.setTester(group.get("_Tester_").toString());
				if(group.get("GCZJ")!=null) {
					powerfulEntity.setGczj(group.get("GCZJ").toString());
				}
				if(group.get("Area")!=null) {
				powerfulEntity.setArea(group.get("Area").toString());
				}
				if(group.get("So")!=null) {
				powerfulEntity.setSo(group.get("So").toString());
				}
				if(group.get("Shape")!=null) {
				powerfulEntity.setShape(group.get("Shape").toString());
				}
				if(group.get("Size")!=null) {
				powerfulEntity.setSize(group.get("Size").toString());
				}
				if(group.get("Span")!=null) {
				powerfulEntity.setSpan(group.get("Span").toString());
				}
				if(group.get("Length")!=null) {
				powerfulEntity.setLength(group.get("Length").toString());
				}
				if(group.get("Width")!=null) {
				powerfulEntity.setWidth(group.get("Width").toString());
				}
				if(group.get("Height")!=null) {
				powerfulEntity.setHeight(group.get("Height").toString());
				}
				if(group.get("do")!=null) {
				powerfulEntity.setDos(group.get("do").toString());
				}
				if(group.get("ZJ")!=null) {
				powerfulEntity.setZj(group.get("ZJ").toString());
				}
				powerfulEntity.setCreateDate(new Date());
				//存储试样主表信息
				powerfulMachineService.savePowerfulData(powerfulEntity);
				//获取试样详细信息
				JSONArray detailArray= group.getJSONArray("Detail");
				List<LaboratoryMechanicsAllPowerfulMachineDetailEntity> detailList = new ArrayList<LaboratoryMechanicsAllPowerfulMachineDetailEntity>();
				for (Object object : detailArray) {
					JSONObject detailObj = (JSONObject) JSONUtil.parse(object);
					LaboratoryMechanicsAllPowerfulMachineDetailEntity entity = new LaboratoryMechanicsAllPowerfulMachineDetailEntity();
					entity.setSampleId(powerfulEntity.getId());
					entity.setSampleKey(group.get("_Key_").toString());
					entity.setDetailKey(detailObj.get("_Key_").toString());
					entity.setTime(detailObj.get("_Time_").toString());
					entity.setDatas(detailObj.get("_Datas_").toString());
					entity.setLo(detailObj.get("Lo").toString());
					entity.setFm(detailObj.get("Fm").toString());
					entity.setRm(detailObj.get("Rm").toString());
					entity.setFeH(detailObj.get("FeH").toString());
					entity.setReH(detailObj.get("ReH").toString());
					entity.setFeL(detailObj.get("FeL").toString());
					entity.setReL(detailObj.get("ReL").toString());
					entity.setLu(detailObj.get("Lu").toString());
					entity.setA(detailObj.get("a").toString());
					entity.setLc(detailObj.get("lc").toString());
					entity.setStdRe(detailObj.get("StdRe").toString());
					entity.setSu(detailObj.get("Su").toString());
					entity.setZ(detailObj.get("Z").toString());
					entity.setFp(detailObj.get("Fp").toString());
					entity.setRp(detailObj.get("Rp").toString());
					entity.setFt(detailObj.get("Ft").toString());
					entity.setRt(detailObj.get("Rt").toString());
					entity.setE(detailObj.get("E").toString());
					entity.setDlm(detailObj.get("DLm").toString());
					entity.setAgt(detailObj.get("Agt").toString());
					entity.setAt(detailObj.get("At").toString());
					entity.setLm(detailObj.get("Lm").toString());
					entity.setAg(detailObj.get("Ag").toString());
					entity.setDltz(detailObj.get("DLTZ").toString());
					entity.setDlxz(detailObj.get("DLXZ").toString());
					entity.setDlwz(detailObj.get("DLWZ").toString());
					entity.setDatas(detailObj.get("_Datas_").toString());
					detailList.add(entity);
				}
				//试样详细信息批量插入数据库
				powerfulMachineDetailService.saveDetailData(detailList);
			}else {
				resultMap.put("result",0);
				resultMap.put("message", "失败原因：_TestID_传参格式有误");
				return resultMap;
			}
			} catch (Exception e) {
				e.printStackTrace();
				resultMap.put("result",0);
				resultMap.put("message", "失败原因："+e.getMessage());
				return resultMap;
			}
			resultMap.put("result",1);
			resultMap.put("message", "上传数据成功");
			return resultMap;
		 }
		//失败
		resultMap.put("result",0);
		resultMap.put("message", "失败原因：上传数据格式异常");
		return resultMap;
	}
	@Override
	public IPage<LaboratoryMechanicsPressMachineDto> page(Map<String, Object> params) {
//		IPage<LaboratoryMechanicsPressMachineDto> page = baseServiceComponent.getPage(params, LaboratoryMechanicsPressMachineDto.class);
		IPage<LaboratoryMechanicsPressMachineDto> resultIPage = mapper.selectPage(null, params);

		return resultIPage;
	}

	@Autowired
	private MechanicsWGroupService groupService;
	@Autowired
	private MechanicsWDetailService wdetailService;
	/**
	 * 接收万能机数据库传入数据
	 */
	@Override
	@Transactional
	public Integer saveDataBaseUpload(JSONObject json) {
		MechanicsWGroupEntity group = new MechanicsWGroupEntity();
		//拼装万能机试验数据
		group.setArea(json.getFloat("area"));
		group.setGczj(json.getFloat("gCZJ"));
		group.setLo(json.getFloat("lo"));
		group.setSylx(json.get("sYLX").toString());
		//group.setId(json.get("iNDEX_ID"));
		group.setSysj(json.getDate("sYSJ"));
		group.setTester(json.get("tester").toString());
		group.setSysl(Integer.parseInt(json.get("sYSL").toString()));
		group.setType(json.get("type").toString());
		group.setMachine(json.get("machine").toString());
		group.setSybh(json.get("sYBH").toString());
		group.setSourceId(Integer.parseInt(json.get("iD").toString()));
		group.setTag(Integer.parseInt(json.get("tag").toString()));
		group.setCreateDate(new Date());
		groupService.save(group);
		//获取试样详细信息
		JSONArray detailArray= json.getJSONArray("detailList");
		List<MechanicsWDetailEntity> detailList = new ArrayList<MechanicsWDetailEntity>();
		for (Object object : detailArray) {
			JSONObject detailObj = (JSONObject) JSONUtil.parse(object);
			MechanicsWDetailEntity detail = new MechanicsWDetailEntity();
			detail.setA(detailObj.getFloat("a"));
			detail.setAgt(detailObj.getFloat("agt"));
			detail.setArea(detailObj.getFloat("area"));
			detail.setAt(detailObj.getFloat("at"));
			detail.setFeh(detailObj.getFloat("feH"));
			detail.setFel(detailObj.getFloat("feL"));
			detail.setFm(detailObj.getFloat("fm"));
			detail.setFp(detailObj.getFloat("fp"));
			detail.setGczj(detailObj.getFloat("gCZJ"));
			detail.setGroupId(group.getId());
			//detail.setGroupId(detailObj.get("gROUP_INDEX_ID"));
			//detail.setId(detailObj.get("iNDEX_ID"));
			detail.setLe(detailObj.getFloat("le"));
			detail.setLo(detailObj.getFloat("lo"));
			detail.setLu(detailObj.getFloat("lu"));
			detail.setReh(detailObj.getFloat("reH"));
			detail.setRel(detailObj.getFloat("reL"));
			detail.setRm(detailObj.getFloat("rm"));
			detail.setRp(detailObj.getFloat("rp"));
			detail.setTestbegin(detailObj.getDate("testBegin"));
			detail.setTestend(detailObj.getDate("testEnd"));
			detail.setType(detailObj.get("type").toString());
			detail.setXh(Integer.parseInt(detailObj.get("xH").toString()));
			detail.setYsgcsj(detailObj.get("ySGCSJ").toString());
			detail.setDlwz(detailObj.get("dLWZ").toString());
			detail.setDlxz(detailObj.get("dLXZ").toString());
			detailList.add(detail);
		}
		wdetailService.saveBatch(detailList);
		return Integer.parseInt(json.get("iNDEX_ID").toString());
	}
	@Autowired
	private MechanicsYGroupService ygroupService;
	@Autowired
	private MechanicsYDetailService ydetailService;
	@Override
	@Transactional
	public Integer saveDataBaseUploadPress(JSONObject json) {
		//拼装压力机试验数据
		MechanicsYGroupEntity group = new MechanicsYGroupEntity();
		group.setPdjg(json.get("pDJG").toString());
		group.setShape(json.get("shape").toString());
		group.setLq(json.get("lQ").toString());
		group.setSylx(json.get("sYLX").toString());
		group.setSysj(json.getDate("sYSJ"));
		group.setTester(json.get("tester").toString());
		group.setPingzhong(json.get("pingZhong").toString());
		group.setSysl(Integer.parseInt(json.get("sYSL").toString()));
		group.setYxqd(json.get("yXQD").toString());
		group.setType(json.get("type").toString());
		group.setQddj(json.get("qDDJ").toString());
		group.setSize(json.get("size").toString());
		group.setYxlz(json.getFloat("yXLZ"));
		group.setMachine(json.get("machine").toString());
		group.setSybh(json.get("sYBH").toString());
		group.setTag(Integer.parseInt(json.get("tag").toString()));
		group.setSourceId(Integer.parseInt(json.get("iD").toString()));
		group.setXs(json.getFloat("xS"));
		group.setCreateDate(new Date());
		ygroupService.save(group);
		//获取试样详细信息
		JSONArray detailArray= json.getJSONArray("detailList");
		List<MechanicsYDetailEntity> detailList = new ArrayList<MechanicsYDetailEntity>();
		for (Object object : detailArray) {
			JSONObject detailObj = (JSONObject) JSONUtil.parse(object);
			MechanicsYDetailEntity detail = new MechanicsYDetailEntity();
			//拼装压力机试验详情数据
			detail.setGroupId(group.getId());
			detail.setLoad(detailObj.getFloat("load"));
			detail.setPingzhong(detailObj.get("pingZhong").toString());
			detail.setQddj(detailObj.get("qDDJ").toString());
			detail.setShape(detailObj.getInt("shape"));
			detail.setSize(detailObj.get("size").toString());
			detail.setStress(detailObj.getFloat("stress"));
			detail.setTestbegin(detailObj.getDate("testBegin"));
			detail.setTestend(detailObj.getDate("testEnd"));
			detail.setType(detailObj.get("type").toString());
			detail.setXh(detailObj.getInt("xH"));
			detail.setXs(detailObj.getFloat("xS"));
			detail.setYsgcsj(detailObj.get("ySGCSJ").toString());
			detailList.add(detail);
		}
		ydetailService.saveBatch(detailList);
		return json.getInt("iD");
	}

	@Override
	public Integer saveDataBaseUploadOUKPress(JSONObject json) {
		//拼装压力机试验数据
		MechanicsYGroupEntity group = new MechanicsYGroupEntity();
		//简单的评定结果，联网厂家的评定方式与我们不同的话请自行处理
		group.setPdjg("");
		//截面形状，0表示圆形，1表示矩形，2表示方形，3表示不规则，4表示无法识别
		group.setShape("4");
		//龄期 针对有龄期的试验如水泥,其它试验忽略
		group.setLq(json.get("lq").toString());
		//试验类型，用于识别相应试验
		group.setSylx(json.get("synx").toString());
		//实验时间
		group.setSysj(json.getDate("date_time"));
		//试验员
		group.setTester("");

		//group.setPingzhong(json.get("pingZhong"));

		//本组的试样数量
		group.setSysl(json.getInt("numb"));
		//有效强度
		group.setYxqd(json.get("yxqd").toString());
		//数据来源
		group.setType(json.get("zDBH").toString());
		//强度等级
		group.setQddj(json.get("qddj").toString());
		//根据截面形状不同，表示的含义不同。圆形为直径或者直径高度；矩形为宽厚或者宽厚高，方
		group.setSize(json.get("sjgg").toString());
		//有效力值
		group.setYxlz(json.getFloat("yxlz"));
		//设备编号
		group.setMachine("");
		//试验编号、欧凯填入外部编号数值
		group.setSybh(json.get("wbbh").toString());
		//状态标记 0:该组试验未完成 1:该组试验完成
		group.setTag(1);
		//数据抽取源表主键
		group.setSourceId(json.getInt("iD"));
		//系数,有些试验在不是标准规格的时候，可能需要转换系数
		try{
			//欧凯使用的是修正系数字段
			group.setXs(json.getFloat("xzxs"));
		}catch (Exception e){
			group.setXsok(json.get("xzxs").toString());
		}
		//创建时间
		group.setCreateDate(new Date());
		//加荷速度
		group.setSpeed(json.get("speed").toString());
		//跨距
		group.setKj(json.get("kj").toString());
		//面积
		group.setMj(json.get("mj").toString());
		//欧凯数据文件（曲线数据在这个指定的文件内）
		group.setSjwj(json.get("sjwj").toString());
		ygroupService.save(group);
		//获取试样详细信息
		List<MechanicsYDetailEntity> detailList = new ArrayList<MechanicsYDetailEntity>();
		int numb = json.getInt("numb");
		for (int i = 1; i <= numb; i++) {
			String zhz = json.getStr("zhz"+i);
			String qdz = json.getStr("qdz"+i);
			MechanicsYDetailEntity detail = new MechanicsYDetailEntity();
			//拼装压力机试验详情数据
			detail.setGroupId(group.getId());
			//极限荷载(kN）
			detail.setLoad(Float.parseFloat(zhz));
			//极限强度(Mpa)
			detail.setStress(Float.parseFloat(qdz));
			detail.setPingzhong(json.get("sjpz").toString());
			detail.setQddj(json.get("qddj").toString());
			//截面形状，0表示圆形，1表示矩形，2表示方形，3表示不规则。
			detail.setShape(4);
			//根据截面形状不同，表示的含义不同。圆形为直径或者直径高度；矩形为宽厚或者宽厚高，方形
			detail.setSize(json.get("sjgg").toString());
//			detail.setTestbegin(json.getDate("date_time"));
//			detail.setTestend(json.getDate("date_time"));
			//终端编号
			detail.setType(json.get("zDBH").toString());
			//序号 代表第几块
			detail.setXh(i);
			try{
				detail.setXs(json.getFloat("xzxs"));
			}catch (Exception e){

			}
			detailList.add(detail);
		}
		ydetailService.saveBatch(detailList);
		return json.getInt("iD");
	}
	@Autowired
	private MechanicsWFyDetailService wfyService;
	@Override
	public Integer saveDataBaseUploadFYAllPurpose(JSONObject json) {
		MechanicsWGroupEntity group = new MechanicsWGroupEntity();
		//拼装万能机试验数据
//		group.setArea(json.getFloat("area"));
//		group.setGczj(json.getFloat("gCZJ"));
//		group.setLo(json.getFloat("lo"));
		group.setSylx(json.get("sYLX").toString());
		group.setSysj(json.getDate("sYSJ"));
//		group.setTester(json.get("tester"));
		group.setSysl(json.getInt("sYSL"));
		group.setType(json.get("zDBH").toString());
//		group.setMachine(json.get("machine").toString());
		group.setSybh(json.get("sYBH").toString());
		group.setSourceId(json.getInt("iD"));

		if("已完成".equals(json.get("tag"))){
			group.setTag(1);
		}else{
			group.setTag(0);
		}
		group.setCreateDate(new Date());
		group.setSourceType("1");
		//判断该组数据简介是否进行维护
		QueryWrapper query = new QueryWrapper();
		query.eq("SYBH",group.getSybh());
		query.eq("type",group.getType());
		MechanicsWGroupEntity groupDate =groupService.getOne(query);
		if(groupDate==null){
			groupService.save(group);
		}
		//详情数据维护
		MechanicsWFyDetailEntity detail = new MechanicsWFyDetailEntity();
		if(groupDate==null){
			detail.setGroupId(group.getId());
		}else{
			detail.setGroupId(groupDate.getId());
		}
		detail.setSybh(json.get("sYBH").toString());
		detail.setLq(json.get("lQ").toString());
		detail.setXh(json.get("xH").toString());
		detail.setSysl(json.get("sYSL").toString());
		detail.setTag(json.get("tag").toString());
		detail.setSylx(json.get("sYLX").toString());
		detail.setSysj(json.getDate("sYSJ"));
		detail.setCxsj(json.get("cXSJ").toString());
		detail.setZdsl(json.get("zDSL").toString());
		detail.setSblc(json.get("sBLC").toString());
		detail.setLzdw(json.get("lZDW").toString());
		detail.setZdl(json.get("zDL").toString());
		detail.setQfd(json.get("qFD").toString());
		detail.setRp02(json.get("rp02").toString());
		detail.setYsgcsj(json.get("ySGCSJ").toString());
		detail.setType(json.get("zDBH").toString());
		wfyService.save(detail);
		return json.getInt("iD");
	}

}
